<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="<?php echo base_url() . '/style/admin/css/public.css' ?>">
    <script type="application/javascript" charset="UTF-8" src="<?php echo base_url() .'/style/admin/js/jquery-1.7.2.min.js' ?>"></script>
    <title>Document</title>
    <script type="application/javascript" charset="UTF-8">
        $(function () {
            // 全选操作
            $("#selectAll").click(function () {
                $("input[name='check']").attr("checked",this.checked);
            });
        });

        // 批量删除 / 批量推荐
        function operation (msg) {
            var pid = '';
            var info = msg=='recover'?'恢复':'彻底删除';
            $("input[name='check']").each(function () {
                if (this.checked) {
                    pid += $(this).val() + ',';
                }
            });

            if (pid === '') {
                alert('没有勾选任何选项');
            } else {
                $.ajax({
                    type : 'post',
                    data : {"aid":pid},
                    url  : "<?php echo site_url('admin/article/multiple')?>/"+msg,
                    success : function (data) {
                        if (data == 'success') {
                            alert('批量'+info+'成功');
                            window.location.href = '<?php echo site_url('admin/article/delArticle')?>';
                        }
                        if (data == 'fail') {
                            alert('批量'+info+'失败');
                            window.location.href = '<?php echo site_url('admin/article/delArticle')?>';
                        }
                    }
                });
            }
            return false;
        }
    </script>
</head>
<body>
<table class="table">
    <tr>
        <td class="th" colspan="10">查看文章</td>
    </tr>

    <tr>
        <td width="8%">AID</td>
        <td>标题</td>
        <td>栏目</td>
        <td>点击量</td>
        <td>发表时间</td>
        <td width="15%">操作</td>
    </tr>

    <?php foreach($art as $key=>$item): ?>
        <tr>
            <td><input type="checkbox" name="check" value="<?php echo $item['aid'] ?>"/>&nbsp;&nbsp;&nbsp;&nbsp;
                <?php echo $item['aid'] ?></td>
            <td><?php echo $item['title'] ?></td>
            <td><?php echo $item['cname'] ?></td>
            <td><?php echo $item['click'] ?></td>
            <td><?php echo date('Y-m-d H:i', $item['time']) ?></td>
            <td>
                [<a href="<?php echo site_url('admin/article/operation/recoverArticle/'.$item['aid']); ?>">恢复</a>]
                [<a href="<?php echo site_url('admin/article/operation/deleteArticle/'.$item['aid']); ?>">彻底删除</a>]
            </td>
        </tr>
    <?php endforeach; ?>
    <tr>
        <td>
            <input type="checkbox" name="selectAll" id="selectAll"/>&nbsp; 全选
        </td>
        <td colspan="10">
            <a href="javascript:void(0);" class="aBtn" onclick="operation('recover');">批量恢复</a>&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="javascript:void(0);" class="aBtn" onclick="operation('delete');">批量彻底删除</a>
        </td>
    </tr>
</table>

<div class="page"><?php echo $link; ?></div>
</body>
</html>